<?

$tmppath="../../";
REQUIRE ($tmppath."include/login.php");
REQUIRE ($tmppath.$templates."up.php");
REQUIRE($tmppath."protect/connect.php");






IF (!empty($mode)){

IF ($categ!='0'){
  $categorie=$categ;
   $querytmp2="AND invention_categorie='$categorie'";
             }

}








$query="SELECT con_sort FROM SDconnP where con_id=$userperso";
$resultat=mysql_query($query);
$tmp=mysql_fetch_row($resultat);
$inventiontmp=EXPLODE("/",$tmp[0]);

$nbr_invention=count($inventiontmp);

FOREACH($inventiontmp as $element){
    if ($drap==1){ $querytmp.=" OR ";}ELSE{$querytmp.=" WHERE (";}
    $i=$element;
    $invention[$i]=1;
    $querytmp.="sort_id=$i";
    $drap=1;
}    //Fin du foreach



$query="SELECT sort_categorie FROM Usort $querytmp ) AND sort_scategorie='Base'";
$resultat=mysql_query($query);


//Afficher le menu du haut.
//*************************
echo"<BR><table width=\"300\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\">
  <tr>
    <td><div align=\"center\">
        <form name=\"form1\" method=\"post\" action=\"\">
          <select name=\"categ\">
            <option value=\"0\">Tous</option>";

WHILE ($tmp=mysql_fetch_array($resultat)){
echo"<option value=\"$tmp[0]\">$tmp[0]</option>";


}


          echo"</select>
          <br>
          <input name=\"mode\" type=\"hidden\" id=\"mode\" value=\"1\">
          
          <input name=\"$SID\" type=\"hidden\" id=\"$SID\" value=\"$SID\">
          

          <BR><input type=\"submit\" name=\"Submit\" value=\"Visionner\">
        </form>
      </div></td>
  </tr>
</table>";








//Chercher les inventions
//***********************


$query="SELECT sort_id, sort_name, sort_icon, sort_categorie,sort_scategorie, sort_magie, sort_niveau FROM Usort $querytmp ) $querytmp2";
$resultat=mysql_query($query);

ECHO "<BR><table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >";
ECHO"<table width=\"95%\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\">
  <tr>
    <td><table width=\"100%\" border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td width=\"50\" background=\"../../templates/default/FondS.jpg\"><div align=\"center\"><strong>Image</strong></div></td>
          <td background=\"../../templates/default/FondS.jpg\"><div align=\"center\"><strong>Nom</strong></div></td>
          <td background=\"../../templates/default/FondS.jpg\"><div align=\"center\"><strong>Categorie</strong></div></td>
          <td background=\"../../templates/default/FondS.jpg\"><div align=\"center\"><strong>Niveau</strong></div></td>
          <td background=\"../../templates/default/FondS.jpg\"><div align=\"center\"><strong>Sous-cat</strong></div></td>
          <td background=\"../../templates/default/FondS.jpg\"><div align=\"center\"><strong>Sorte</strong></div></td>
        </tr>";

$var_tmp=0;
$nbr_cat=0;

WHILE ($tmp=mysql_fetch_array($resultat)){

$nbr_cat++;
IF ($var_tmp==0){
$bgr="background=\"../../templates/default/FondC.jpg\"";
$var_tmp=1;

}
ELSE{
$bgr="";
$var_tmp=0;

}
$query="SELECT invention_name FROM Invention WHERE invention_id=$tmp[4]";
$resultat2=mysql_query($query);
$tmp2=mysql_fetch_array($resultat2);
//<img src=\"../../images/invention/$tmp[2]\">

ECHO"<tr>
          <td $bgr></td>
          <td $bgr>$tmp[1]</td>
          <td $bgr>$tmp[3]</td>
          <td $bgr>$tmp[6]</td>
          <td $bgr>$tmp2[0]</td>
          <td $bgr>$tmp[5]</td>

          </tr>";





}

echo "</table></table><br>";

//Affichage des caracteristique des invention.
//********************************************

echo"<table width=\"300\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\">
  <tr>
    <td><div align=\"center\">Nombre de sorts total : $nbr_invention<br>" ;
    
IF (!empty($mode)){

IF ($categ!='0'){
 echo" Invention(s) de cat&eacute;gorie $categorie : $nbr_cat</div></td>";

             }

}






        



echo"</tr></table>";

?>

